package cn.donghuapian.service.impl;

import cn.donghuapian.entity.UserEntity;
import cn.donghuapian.mapper.UserMapper;
import cn.donghuapian.service.IUserService;
import cn.donghuapian.vo.ResponseBody;
import cn.donghuapian.vo.UserVO;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hzw
 * @since 2024-09-26
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements IUserService {

    @Override
    public ResponseBody<UserVO> login(UserEntity entity) {

        LambdaQueryWrapper<UserEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserEntity::getAccount, entity.getAccount());
        queryWrapper.eq(UserEntity::getPassword, entity.getPassword());
        UserEntity user = this.getOne(queryWrapper);
        if (null == user) {
            return ResponseBody.error("用户名或密码错误");
        }
        return ResponseBody.success();
    }
}
